var { ReturnModel } = require('../libs/resmodel');
var { feedAdd, feedList } = require('../services/feedback');

/**
* 反馈
* @api {post} /feedback/add 反馈
* @apiDescription 反馈
* @apiName add
* @apiParam (参数) {String} pcode 当前用户code
* @apiParam (参数) {String} fcode 被反馈用户code
* @apiParam (参数) {String} opinion 反馈意见
* @apiSampleRequest /feedback/add
* @apiGroup feedback-反馈
* @apiVersion 1.0.0
* @apiParamExample {json} Request-Example:
*     {
*       "pcode": "290464549598", 
*       "fcode": "249485919615",
*       "opinion": "没有眼缘,兴趣不合"
*     }
* @apiSuccessExample {json} Success-Response:
*   HTTP/1.1 200 OK
*   {
*      "msg": "反馈成功",
*      "code": 0
*   }
*/
async function add(req, res) {
    let result = await feedAdd(req.body);
    res.json(new ReturnModel(result));
}
/**
* 反馈列表
* @api {post} /feedback/list 反馈列表
* @apiDescription 反馈列表
* @apiName list
* @apiParam (参数) {Number} pagenum 查询第几页
* @apiParam (参数) {Number} pagesize 每页显示条数
* @apiSampleRequest /feedback/list
* @apiGroup feedback-反馈
* @apiVersion 1.0.0
* @apiParamExample {json} Request-Example:
*    {
*     "pagenum": 1,  // 查询第几页
*     "pagesize": 10,  // 每页显示条数
*    }
* @apiSuccessExample {json} Success-Response:
*   HTTP/1.1 200 OK
*   {
*      "data": {
*              "list": [
*                   pdata: {"nickname":"xxxx","code":"","avator":""},// 反馈用户信息
*                   fdata: {"nickname":"xxxx","code":"","avator":""}, // 被反馈用户信息
*                   opinion: "兴趣不合,非原生家庭", // 反馈信息，
*                   updatetime: "2022-07-15 12:32", // 反馈时间
*                ],
*              "total": 200,//总条数
*              "pagecount": 20,//总页数
*       },
*      "msg": "获取成功",
*      "code": 0
*   }
*/
async function list(req, res) {
    let result = await feedList(req);
    res.json(new ReturnModel(result));
}

module.exports = function (app) {
    let base_url = '/api/feedback';

    app.post(base_url+'/add', add);
    app.post(base_url+'/list', list);
}
